import { app, BrowserWindow, shell } from 'electron';
import { desktop } from '../config';
import path from 'path';
var vipWin: any;
export default function create_desktop_window(mainWindow: any) {
  return new Promise((reject, resolve) => {
    if (vipWin) {
      vipWin.show();
    } else {
      vipWin = new BrowserWindow({
        width: 400,
        height: 550,
        parent: mainWindow, // win是主窗口
        ...desktop,
      });
      if (process.env.NODE_ENV === 'development') {
        let filePath = path.join(__dirname, '../../index.html');
        vipWin.loadURL(`file://${filePath}#/desktop`);
      } else {
        vipWin.loadURL(`file://${__dirname}/index.html#/desktop`);
      }
      vipWin.on('closed', () => {
        vipWin = null;
      });
      vipWin.once('ready-to-show', () => {
        reject(vipWin);
      });
    }
  });
}
